home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_08_04
/
8n04126a
< prev
next >
Wrap
Text File
|
1990-03-18
|
2KB
|
58 lines
*****Listing 1*****
#!/usr/local/bin/perl
eval "exec /usr/local/bin/perl -S $0 $*"
if $running_via_sh;
# A cute Berkeley style df formatter for those running USG df
# Do what you want with it; it's yours.
# R. Craig Peterson, N8INO
$fs=join(' ',@ARGV);
open(Df, "df -t $fs|") || die "Can't run df.";
format top =
Filesystem kbytes used avail capacity iused ifree %iused Device
format STDOUT =
@<<<<<<<<<<<<<< @>>>>>> @>>>>>> @>>>>> @>% @>>>>> @>>>>> @>% @<<<<<<<<<<<<<<
$fs $kbytes $used $avail $capacity $iused $inodes $piused $name
while (<Df>) {
if (/total blocks/) {
($d,$tblocks,$d,$d,$tinodes,$d) = split(' ');
$tinodes *= 8;
$kbytes = $tblocks / 2;
$used = ($tblocks - $blocks) / 2;
$avail = $blocks / 2;
$capacity = int(100 - ($blocks / $tblocks * 100));
$iused = $tinodes - $inodes;
$piused = int($iused / $tinodes * 100);
write;
$tot_kbytes += $kbytes;
$tot_used += $used;
$tot_avail += $avail;
$tot_iused += $iused;
$tot_inodes += $inodes;
$tot_tinodes += $tinodes;
} else {
s/\(\s*/ \(/;
s/\s*\)/\)/;
($fs,$name,$blocks,$d,$inodes,$d) = split;
$name =~ s![(): \t]|/dev/dsk/!!g;
}
}
if ($#ARGV < 0) {
$kbytes = $tot_kbytes;
$used = $tot_used;
$avail = $tot_avail;
$capacity = int(100 - ($avail / $kbytes * 100));
$iused = $tot_iused;
$inodes = $tot_inodes;
$tinodes = $tot_tinodes;
$piused = int($iused / $tinodes * 100);
$fs = 'Totals:';
$name = '';
write;
}